import request from '@/utils/request'

// 查询店铺列表
export function listShop(query) {
  return request({
    url: '/biz/shop/list',
    method: 'get',
    params: query
  })
}

// 查询店铺详细
export function getShop(id) {
  return request({
    url: '/biz/shop/' + id,
    method: 'get'
  })
}

// 新增店铺
export function addShop(data) {
  var params = data;
  if (typeof params.jycategory !== "string") {
    params.jycategory = params.jycategory.join(',')
  }
  if(typeof params.jypipai !== "string"){
    params.jypipai = params.jypipai.join(',')
  }
  return request({
    url: '/biz/shop',
    method: 'post',
    data: params
  })
}

// 修改店铺
export function updateShop(data) {
  //data.jycategory = data.jycategory.join(',')
  //data.jypipai = data.jypipai.join(',')

  var params = data;
  if (typeof params.jycategory !== "string") {
    params.jycategory = params.jycategory.join(',')
  }
  if(typeof params.jypipai !== "string"){
    params.jypipai = params.jypipai.join(',')
  }
  return request({
    url: '/biz/shop',
    method: 'put',
    data: params
  })
}

// 删除店铺
export function delShop(id) {
  return request({
    url: '/biz/shop/' + id,
    method: 'delete'
  })
}

// 导出店铺
export function exportShop(query) {
  return request({
    url: '/biz/shop/export',
    method: 'get',
    params: query
  })
}